﻿@model Gluten.Models.SelectPages
@{
    ViewBag.Title = "Menu - " + ViewBag.Menu.Name;
    Layout = "_Layout.cshtml";
}
<h2>@ViewBag.Menu.Name</h2>
Action for selected:<br />
@using (Html.BeginForm("Menu", "Admin", FormMethod.Post, new { @id = "selectForm" }))
{
    <div>
        <input type="hidden" name="Action" id="pages_action" />
        <strong>
            <input type="button" value="Delete" onclick="sendForDelete()"/></strong>
        |
        <select id="move_select" onchange="sendForMove()" name="Destination">
            <option value="0">Move to...</option>
            @foreach (var menu in @ViewBag.Menus)
            {
                <option value = "@menu.Id">@menu.Name</option>
            }
        </select><br />
        <br />
        Pages
        <br />
        <table class="menu_table" id="pages_table">
            <thead>
                <tr>
                    <td>
                        Check
                    </td>
                    <td>
                        Menu
                    </td>
                </tr>
            </thead>
            @for (int i = 0; i < ViewBag.Pages.Count; i++)
            {
                <tr>
                    <td class="text_center">
                        @Html.CheckBoxFor(model => model.PagesFlag[i])
                        <input type="hidden" name = "PageGuid", value="@ViewBag.Pages[i].Id" />
                    </td>
                    <td>
                        <strong><a href="@Url.Action("Page", "Admin", new { @id = @ViewBag.Pages[i].Id })">
                            @ViewBag.Pages[i].Title
                        </a></strong>
                    </td>
                </tr>
            }
        </table>
    </div>
}
<strong><a href="@Url.Action("CreatePage", "Admin", new { @id = @ViewBag.Menu.Id })">
    Create Page →</a><br />
</strong>